home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / documentation / tutorial / intl / datamgmt / demos-1.1 / DemoApplet.java < prev    next >
Encoding:
Java Source  |  1997-07-13  |  3.2 KB  |  95 lines

  1. /*
  2.  * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software
  5.  * and its documentation for NON-COMMERCIAL purposes and without
  6.  * fee is hereby granted provided that this copyright notice
  7.  * appears in all copies. Please refer to the file "copyright.html"
  8.  * for further important copyright and licensing information.
  9.  *
  10.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  11.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  12.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  13.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  14.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  15.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  16.  */
  17. /*
  18.  * @(#)DemoApplet.java    1.1 96/11/23
  19.  *
  20.  * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
  21.  * (C) Copyright IBM Corp. 1996 - All Rights Reserved
  22.  *
  23.  * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
  24.  *
  25.  *   The original version of this source code and documentation is copyrighted
  26.  * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
  27.  * materials are provided under terms of a License Agreement between Taligent
  28.  * and Sun. This technology is protected by multiple US and International
  29.  * patents. This notice and attribution to Taligent may not be removed.
  30.  *   Taligent is a registered trademark of Taligent, Inc.
  31.  *
  32.  * Permission to use, copy, modify, and distribute this software
  33.  * and its documentation for NON-COMMERCIAL purposes and without
  34.  * fee is hereby granted provided that this copyright notice
  35.  * appears in all copies. Please refer to the file "copyright.html"
  36.  * for further important copyright and licensing information.
  37.  *
  38.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  39.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  40.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  41.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  42.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  43.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  44.  *
  45.  */
  46.  
  47.  
  48. import java.applet.Applet;
  49. import java.awt.*;
  50.  
  51. import java.awt.event.ActionListener;
  52. import java.awt.event.ActionEvent;
  53.  
  54. public abstract class DemoApplet extends java.applet.Applet implements ActionListener
  55. {
  56.     private Button   demoButton;
  57.     private Frame    demoFrame;
  58.  
  59.     public abstract Frame createDemoFrame(DemoApplet applet);
  60.  
  61.     //Create a button that will display the demo
  62.     public void init()
  63.     {
  64. //      setBackground(Color.white);
  65.         demoButton = new Button("Demo");
  66. //      demoButton.setBackground(Color.yellow);
  67.     demoButton.addActionListener(this);
  68.         add( demoButton );
  69.     }
  70.     public static void showDemo(Frame demoFrame)
  71.     {
  72.     demoFrame.setSize(550,500);
  73.     demoFrame.show();
  74.     }
  75.  
  76.     public void demoClosed()
  77.     {
  78.         demoFrame = null;
  79.     }
  80.  
  81.     public void actionPerformed(ActionEvent event)
  82.     {
  83.     demoButton.setLabel("loading");
  84.  
  85.     if (demoFrame == null) {
  86.        demoFrame = createDemoFrame(this);
  87.            showDemo(demoFrame);
  88.     } else
  89.            demoFrame.show();
  90.  
  91.     demoButton.setLabel("Demo");
  92.     }
  93. }
  94.  
  95.